package com.huadao.cart_ccs.data.bo;

import com.huadao.cart_ccs.common.ByteUtils;
import com.huadao.cart_ccs.exception.ExceptionCode;
import com.huadao.cart_ccs.exception.ProtocolException;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

@Entity
public class Protocol {
    @Id
    private Long protocolId;
    private long projectId;
    private long stageId;
    private Date date;
    private int type;

    private byte[] head;//报头1
    private byte[] length;//报文长度2
    private byte[] agentNumber;//代理商编号2
    private byte[] mac;//MAC地址6
    private byte[] deviceType;//设备类型1
    private byte[] commandWord;//命令字1
    private byte[] modularOrder;//模块指令2
    private byte[] orderContent;//指令内容N
    private byte[] checkSum;//校验和1
    private byte[] tail;//报尾1

    public static final int type_request=0;
    public static final int type_response=1;

    public Protocol(byte[] head, byte[] length, byte[] agentNumber, byte[] mac, byte[] deviceType, byte[] commandWord, byte[] modularOrder, byte[] orderContent, byte[] checkSum, byte[] tail) {
        this.head = head;
        this.length = length;
        this.agentNumber = agentNumber;
        this.mac = mac;
        this.deviceType = deviceType;
        this.commandWord = commandWord;
        this.modularOrder = modularOrder;
        this.orderContent = orderContent;
        this.checkSum = checkSum;
        this.tail = tail;
    }

    @Generated(hash = 1476775491)
    public Protocol(Long protocolId, long projectId, long stageId, Date date, int type, byte[] head, byte[] length, byte[] agentNumber, byte[] mac, byte[] deviceType, byte[] commandWord,
            byte[] modularOrder, byte[] orderContent, byte[] checkSum, byte[] tail) {
        this.protocolId = protocolId;
        this.projectId = projectId;
        this.stageId = stageId;
        this.date = date;
        this.type = type;
        this.head = head;
        this.length = length;
        this.agentNumber = agentNumber;
        this.mac = mac;
        this.deviceType = deviceType;
        this.commandWord = commandWord;
        this.modularOrder = modularOrder;
        this.orderContent = orderContent;
        this.checkSum = checkSum;
        this.tail = tail;
    }

    @Generated(hash = 140693037)
    public Protocol() {
    }

    public BaseBO parse2BO() throws ProtocolException {
        BaseBO baseBO = null;
        if (commandWord != null && commandWord.length == 1) {
            if (modularOrder != null && modularOrder.length == 3) {
                byte modularType=modularOrder[0];
                byte modularNO = modularOrder[1];
                byte order = modularOrder[2];
                switch (modularType) {
                    case DeviceBO.ModularType_DeviceMAC:
                        baseBO = new DeviceBO();
                        if (ByteUtils.isEqual(commandWord, CommandWord.readSucc)) {
                            if(modularNO==DeviceBO.deviceMAC_NO1) {
                                ((DeviceBO) baseBO).setMAC(mac);
                                ((DeviceBO) baseBO).setAgentNumber(agentNumber);
                            }else if(modularNO==DeviceBO.deviceMAC_NO2){
                                Date date=parseTime(orderContent);
                                ((DeviceBO) baseBO).setDate(date);
                            }else {
                                throw new ProtocolException("wrong modularNO", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if(ByteUtils.isEqual(commandWord, CommandWord.writeSucc)){
                            if(modularNO==DeviceBO.deviceMAC_NO1) {
                                if(orderContent.length!=10){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                byte[] ip = Arrays.copyOfRange(orderContent, 0, 4);
                                byte[] netMask = Arrays.copyOfRange(orderContent, 4, 8);
                                byte[] changedAgentNumber = Arrays.copyOfRange(orderContent, 8, 10);
                                ((DeviceBO) baseBO).setAgentNumber(changedAgentNumber);
                                ((DeviceBO) baseBO).setIp(ip);
                                ((DeviceBO) baseBO).setIp(netMask);
                            }else if(modularNO==DeviceBO.deviceMAC_NO2){
                                Date date=parseTime(orderContent);
                                ((DeviceBO) baseBO).setDate(date);
                            }else if(modularNO==DeviceBO.deviceMAC_SHUTDOWN){

                            }else {
                                throw new ProtocolException("wrong modularNO", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                            baseBO.setError(getErrorCode());
                        }else {
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        }
                        break;
                    case PeristalticPumpBO.ModularType_PeristalticPump:
                        baseBO = new PeristalticPumpBO();
                        if (ByteUtils.isEqual(commandWord, CommandWord.readSucc)) {
                            if (order == PeristalticPumpBO.read) {
                                if(orderContent.length!=4){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                byte[] direction = Arrays.copyOfRange(orderContent, 0, 1);
                                byte[] alarm = Arrays.copyOfRange(orderContent, 1, 2);
                                byte[] speed = Arrays.copyOfRange(orderContent, 2, 4);
                                int speedInt = ByteUtils.bytes2intLH(speed);
                                ((PeristalticPumpBO) baseBO).setSpeed(speedInt);
                                ((PeristalticPumpBO) baseBO).setDirection(direction[0]);
                                ((PeristalticPumpBO) baseBO).setAlarm(alarm[0]);
                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if(ByteUtils.isEqual(commandWord, CommandWord.writeSucc)){
                            if (order == PeristalticPumpBO.star) {
                                if(orderContent.length!=3){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                byte[] speed = Arrays.copyOfRange(orderContent, 0, 2);
                                byte[] direction = Arrays.copyOfRange(orderContent, 2, 3);
                                int speedInt = ByteUtils.bytes2intLH(speed);
                                ((PeristalticPumpBO) baseBO).setSpeed(speedInt);
                                ((PeristalticPumpBO) baseBO).setDirection(direction[0]);
                            } else if (order == PeristalticPumpBO.stop) {

                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                            baseBO.setError(getErrorCode());
                        }else {
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        }
                        break;
                    case MagneticStirrerBO.ModularType_MagneticStirrer:
                        baseBO = new MagneticStirrerBO();
                        if (ByteUtils.isEqual(commandWord, CommandWord.writeSucc)) {
                            if (order == MagneticStirrerBO.star) {
                                if(orderContent.length!=3){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                byte[] speedElectric = Arrays.copyOfRange(orderContent, 0, 2);
                                byte[] directionElectric = Arrays.copyOfRange(orderContent, 2, 3);
                                int speedInt = ByteUtils.bytes2intLH(speedElectric);
                                ((MagneticStirrerBO) baseBO).setSpeed(speedInt);
                                ((MagneticStirrerBO) baseBO).setDirection(directionElectric[0]);
                            }else if(order == MagneticStirrerBO.stop){

                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if(ByteUtils.isEqual(commandWord, CommandWord.readSucc)){
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        } else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                            baseBO.setError(getErrorCode());
                        }else {
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        }
                        break;
                    case TemperatureBO.ModularType_Temperature:
                        baseBO=new TemperatureBO();
                        if (ByteUtils.isEqual(commandWord, CommandWord.readSucc)) {
                            if (order == TemperatureBO.read) {
                                if(orderContent.length!=2){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                double temperature=(double) ByteUtils.bytes2intLH(orderContent)/100;
                                ((TemperatureBO)baseBO).setTemperature(temperature);
                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if(ByteUtils.isEqual(commandWord, CommandWord.writeSucc)){
                            if (order == TemperatureBO.write) {
                                if(orderContent.length!=2){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                double temperature=(double) ByteUtils.bytes2intLH(orderContent)/100;
                                ((TemperatureBO)baseBO).setTemperature(temperature);
                            }else if(order==TemperatureBO.stop){

                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                            baseBO.setError(getErrorCode());
                        }else {
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        }
                        break;
                    case CO2BO.ModularType_Atmosphere:
                        if(modularNO==CO2BO.Atmosphere_CO2){
                            baseBO=new CO2BO();
                            if (ByteUtils.isEqual(commandWord, CommandWord.readSucc)) {
                                if (order == AtmosphereBO.read) {
                                    if(orderContent.length!=2){
                                        throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                    }
                                    double co2=(double) ByteUtils.bytes2intLH(orderContent)/100;
                                    ((CO2BO)baseBO).setCO2(co2);
                                }else {
                                    throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                                }
                            }else if(ByteUtils.isEqual(commandWord, CommandWord.writeSucc)){
                                if(order == AtmosphereBO.write){
                                    if(orderContent.length!=2){
                                        throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                    }
                                    double co2=(double) ByteUtils.bytes2intLH(orderContent)/100;
                                    ((CO2BO)baseBO).setCO2(co2);
                                }else if(order == AtmosphereBO.stop){

                                }else {
                                    throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                                }
                            }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                                baseBO.setError(getErrorCode());
                            }else {
                                throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                            }
                        }else if(modularNO==O2BO.Atmosphere_O2){
                            baseBO=new O2BO();
                            if (ByteUtils.isEqual(commandWord, CommandWord.readSucc)) {
                                if (order == AtmosphereBO.read) {
                                    if(orderContent.length!=2){
                                        throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                    }
                                    double o2=(double) ByteUtils.bytes2intLH(orderContent)/100;
                                    ((O2BO)baseBO).setO2(o2);
                                }else {
                                    throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                                }
                            }else if(ByteUtils.isEqual(commandWord, CommandWord.writeSucc)){
                                if(order == AtmosphereBO.write){
                                    if(orderContent.length!=2){
                                        throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                    }
                                    double o2=(double) ByteUtils.bytes2intLH(orderContent)/100;
                                    ((O2BO)baseBO).setO2(o2);
                                }else if(order == AtmosphereBO.stop){

                                }else {
                                    throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                                }
                            }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                                baseBO.setError(getErrorCode());
                            }else {
                                throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                            }
                        }
                        break;
                    case DoorBO.ModularType_Door:
                        baseBO=new DoorBO();
                        if (ByteUtils.isEqual(commandWord, CommandWord.writeSucc)) {
                            if(order==DoorBO.close||order==DoorBO.open||order==DoorBO.stop){
                                if(orderContent.length!=1){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                ((DoorBO)baseBO).setStatus(orderContent[0]);
                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if(ByteUtils.isEqual(commandWord, CommandWord.readSucc)){
                            if(order==DoorBO.read){
                                if(orderContent.length!=1){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                ((DoorBO)baseBO).setStatus(orderContent[0]);
                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if(ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)){
                            baseBO.setError(getErrorCode());
                        }else {
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        }
                        break;
                    case ElectronicScaleBO.ModularType_ElectronicScale:
                        baseBO = new ElectronicScaleBO();
                        if (ByteUtils.isEqual(commandWord, CommandWord.readSucc)) {//称重
                            if(order==ElectronicScaleBO.read){
                                if(orderContent.length!=2){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                byte[] weight = orderContent;
                                int weightInt = ByteUtils.bytes2intLH(weight);
                                //获得的称重值还要减去参考值
//                                weightInt=weightInt-CartApplication.getInstance().getReferenceWeight();
//                                if(weightInt<0){
//                                    weightInt=0;
//                                }
//                                weightInt= (int) Math.round(ElectronicScaleController.calculatedWeight(weightInt));
                                ((ElectronicScaleBO) baseBO).setWeight((double) weightInt);
                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        } else if(ByteUtils.isEqual(commandWord, CommandWord.writeSucc)){//去皮
                            if(order==ElectronicScaleBO.peel){
                                if(orderContent.length!=4){
                                    throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                }
                                byte[] ad = orderContent;
                                ((ElectronicScaleBO) baseBO).setAd(ad);
                            }else {
                                throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                            }
                        }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                            baseBO.setError(getErrorCode());
                        }else {
                            throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                        }
                        break;
                    case LiquidLevelBO.ModularType_LiquidLevel:
                        baseBO=new LiquidLevelBO();
                        if(order==LiquidLevelBO.read){
                            if(orderContent.length!=1){
                                throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                            }
                            ((LiquidLevelBO) baseBO).setStatus(orderContent[0]);
                        }else {
                            throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                        }
                        break;
                    case VacuumPumpBO.ModularType_VacuumPump:
                        if(modularNO== CultureTankBO.VacuumPump_cultureTank){
                            baseBO = new CultureTankBO();
                            if (ByteUtils.isEqual(commandWord, CommandWord.writeSucc)) {
                                if (order == CultureTankBO.star || order == CultureTankBO.stop) {
                                    if(orderContent.length!=1){
                                        throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                    }
                                    byte[] speedElectric1 = orderContent;
                                    int speedInt = ByteUtils.bytes2intLH(speedElectric1);
                                    ((CultureTankBO) baseBO).setSpeed(speedInt);
                                }else {
                                    throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                                }
                            } else if(ByteUtils.isEqual(commandWord, CommandWord.readSucc)){
                                throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                            }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                                baseBO.setError(getErrorCode());
                            }else {
                                throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                            }
                        }else if(modularNO== IncubatorBO.VacuumPump_incubator){
                            baseBO = new IncubatorBO();
                            if (ByteUtils.isEqual(commandWord, CommandWord.writeSucc)) {
                                if(order==IncubatorBO.star||order==IncubatorBO.stop){
                                    if(orderContent.length!=1){
                                        throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                                    }
                                }else {
                                    throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                                }
                            } else if(ByteUtils.isEqual(commandWord, CommandWord.readSucc)){

                            }else if (ByteUtils.isEqual(commandWord, CommandWord.readFail) || ByteUtils.isEqual(commandWord, CommandWord.writeFail)) {
                                baseBO.setError(getErrorCode());
                            }else {
                                throw new ProtocolException("wrong commandWord", ExceptionCode.COMMOND_WORD,getParams());
                            }
                        }
                        break;
                    case UltravioletLightBO.ModularType_UltravioletLight:
                        baseBO=new UltravioletLightBO();
                        if(order==UltravioletLightBO.on||order==UltravioletLightBO.off){
                            if(orderContent.length!=1){
                                throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
                            }
                            ((UltravioletLightBO)baseBO).setStatus(orderContent[0]);
                        }else {
                            throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                        }
                        break;
                    case ValveBO.ModularType_Valve:
                        baseBO=new ValveBO();
                        if(order==ValveBO.open||order==ValveBO.close){

                        }else {
                            throw new ProtocolException("wrong order", ExceptionCode.MODULAR_ORDER,getParams());
                        }
                        break;
                    default:
                        throw new ProtocolException("wrong modularType", ExceptionCode.MODULAR_ORDER,getParams());
                }
                if (baseBO != null) {
                    baseBO.setCommondWord(commandWord[0]);
                    baseBO.setModularNO(modularNO);
                    baseBO.setModularType(modularType);
                    baseBO.setOrder(order);
                    baseBO.setProtocol(toByteArray());
                }else {
                    baseBO=new BaseBO();
                }
            }
        }
        return baseBO;
    }

    public byte[] toByteArray(){
        byte[] bytes=ByteUtils.mergeByteArray(head,length,agentNumber,mac,deviceType,commandWord,modularOrder,orderContent,checkSum,tail);
        return bytes;
    }

    private Date parseTime(byte[] orderContent) throws ProtocolException {
        if(orderContent==null||orderContent.length!=8){
            throw new ProtocolException("wrong orderContent", ExceptionCode.ORDER_CONTENT,getParams());
        }
        byte yearByte=orderContent[0];
        byte monthByte=orderContent[1];
        byte dayByte=orderContent[2];
        byte weekDayByte=orderContent[3];
        byte hourByte=orderContent[4];
        byte minuteByte=orderContent[5];
        byte secondByte=orderContent[6];
        byte am_pmByte=orderContent[7];

        int year=ByteUtils.byte2int(yearByte);
        Calendar now=Calendar.getInstance();
        now.setTime(new Date());
        int currentYear=now.get(Calendar.YEAR);
        year=currentYear/100*100+year;

        int month=ByteUtils.byte2int(monthByte)-1;
        int day=ByteUtils.byte2int(dayByte);
        int weekDay=ByteUtils.byte2int(weekDayByte);
        if(weekDay==7){
            weekDay=1;
        }else{
            weekDay+=1;
        }
        int hour=ByteUtils.byte2int(hourByte);
        int minute=ByteUtils.byte2int(minuteByte);
        int second=ByteUtils.byte2int(secondByte);
        int am_pm=ByteUtils.byte2int(am_pmByte);

        Calendar calendar=Calendar.getInstance();
        calendar.set(Calendar.YEAR,year);
        calendar.set(Calendar.MONTH,month);
        calendar.set(Calendar.DAY_OF_MONTH,day);
//        calendar.set(Calendar.DAY_OF_WEEK,weekDay);
        calendar.set(Calendar.HOUR,hour);
        calendar.set(Calendar.MINUTE,minute);
        calendar.set(Calendar.SECOND,second);
        calendar.set(Calendar.AM_PM,am_pm);
        return calendar.getTime();
    }

    private byte getErrorCode() {
        if (orderContent != null && orderContent.length == 1) {
            byte[] error = Arrays.copyOfRange(orderContent, 0, 1);
            return error[0];
        } else {
            return 0;
        }
    }

    public byte[] getParams(){
        byte[] params=ByteUtils.mergeByteArray(head,length,agentNumber,mac,deviceType,commandWord,modularOrder,orderContent,checkSum,tail);
        return params;
    }

    @Override
    public String toString() {
        byte[] params=getParams();
        String string= ByteUtils.getHexByte(params,0,params.length);
        return string;
    }

    public byte[] getHead() {
        return head;
    }

    public byte[] getLength() {
        return length;
    }

    public byte[] getAgentNumber() {
        return agentNumber;
    }

    public byte[] getMac() {
        return mac;
    }

    public byte[] getDeviceType() {
        return deviceType;
    }

    public byte[] getCommandWord() {
        return commandWord;
    }

    public byte[] getModularOrder() {
        return modularOrder;
    }

    public byte[] getOrderContent() {
        return orderContent;
    }

    public byte[] getCheckSum() {
        return checkSum;
    }

    public byte[] getTail() {
        return tail;
    }

    public void setHead(byte[] head) {
        this.head = head;
    }

    public void setLength(byte[] length) {
        this.length = length;
    }

    public void setAgentNumber(byte[] agentNumber) {
        this.agentNumber = agentNumber;
    }

    public void setMac(byte[] mac) {
        this.mac = mac;
    }

    public void setDeviceType(byte[] deviceType) {
        this.deviceType = deviceType;
    }

    public void setCommandWord(byte[] commandWord) {
        this.commandWord = commandWord;
    }

    public void setModularOrder(byte[] modularOrder) {
        this.modularOrder = modularOrder;
    }

    public void setOrderContent(byte[] orderContent) {
        this.orderContent = orderContent;
    }

    public void setCheckSum(byte[] checkSum) {
        this.checkSum = checkSum;
    }

    public void setTail(byte[] tail) {
        this.tail = tail;
    }

    public Long getProtocolId() {
        return this.protocolId;
    }

    public void setProtocolId(Long protocolId) {
        this.protocolId = protocolId;
    }

    public Date getDate() {
        return this.date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public int getType() {
        return this.type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Long getProjectId() {
        return this.projectId;
    }

    public void setProjectId(long projectId) {
        this.projectId = projectId;
    }

    public long getStageId() {
        return this.stageId;
    }

    public void setStageId(long stageId) {
        this.stageId = stageId;
    }

}
